doctype
html
    head
        meta(charset="utf-8")
        meta(name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no")
        title #{title}
        link(rel="stylesheet",href="/css/index.css")
        link(rel="stylesheet",href="/css/normalize.css")
        script(src="/js/jquery.js")
        script(src="/js/vendor.js")
        script.
            (function () {
                var deviceWidth = document.documentElement.clientWidth < 640 ? document.documentElement.clientWidth : 640;
                document.documentElement.style.fontSize = deviceWidth / 6.4 + 'px';//640的设计稿
            })();
    body
        if(belongId)
            script.
                var fromId = "#{user._id}";
                var belongId = "#{belongId}";
        else if(user)
            script.
                var fromId = "#{user._id}";
                var belongId = "#{user._id}";
        else
            script.
                var fromId = "";
                var belongId = "";
        if(way)
            script.
                var way="#{way._id}";
                var autoReplay="#{way.autoReplay}";
        else
            script.
                var way="";
        script.
            function iMap() {
                Object.defineProperty(this, 'length', {
                    enumerable: false,
                    configurable: false,
                    writable: true,
                    value: 0
                })
            }
            Object.defineProperties(iMap.prototype, {
                'set': {
                    enumerable: false,
                    configurable: false,
                    writable: false,
                    value: function (obj) {
                        if (this[obj._id] === undefined) {
                            this.length++;
                        }
                        this[obj._id] = obj;
                    }
                },
                'del': {
                    enumerable: false,
                    configurable: false,
                    writable: false,
                    value: function (obj) {
                        console.log(obj);
                        if (this[obj._id]) {
                            console.log(this[obj._id])
                            delete this[obj._id];
                            this.length--;
                        }
                    }
                }
            });
            var INITIAL_STATE_MES_ORIGN = ("#{messages}")?JSON.parse(("#{messages}".replace(/&quot;/ig, '\"'))):[];
            var INITIAL_STATE_MES = new iMap()
            INITIAL_STATE_MES_ORIGN.forEach(function(message){
                INITIAL_STATE_MES.set(message);
            });
        div(id="app" class="container")
        script(src="/socket.io/socket.io.js")
        script(src="/js/index.js")
